define(function (require) {

    $ && $(function () {
        require('jquery-validate');
        require('jquery-metadata');

        var $form = $('#user-register-form'), $name = $('#name'), $pwd = $('#password'), $btnSubmit = $('#btnSubmit');

        var validator = $form.validate({
            // 暂且注释掉,用户测试方便
            rules:{
                name:{
                    remote:{ type:"post", url:"?r=user/exists", dataType:"html",
                        dataFilter:function (data, type) {
                            console.log('dataFilter', data, type);
                            return data != "1";
                        }
                    }
                },
                email:{
                    remote:{ type:"post", url:"?r=email/exists", dataType:"html",
                        dataFilter:function (data, type) {
                            console.log('dataFilter', data, type);
                            return data != "1";
                        }
                    }
                }
            },

            errorPlacement:function (error, element) {
                element.after(error);
            },
            submitHandler:function (form) {
                console.log('正在提交表单...');
                form.submit();
            }
        });
    })
});